<template>
	<view class="u-page">
		<u-empty text="暂无列表哦~~" mode="list" v-if="list.length==0" margin-top='50'></u-empty>
		<u-list @scrolltolower="scrolltolower" lowerThreshold="70" height="auto">
			<u-list-item v-for="(item, index) in list" :key="index">
				<u-cell :title="item.name" @click="goDetails(item)">
					<!-- <u-avatar
						slot="icon"
						shape="square"
						size="35"
						:src="item.url"
						customStyle="margin: -3px 5px -3px 0"
					></u-avatar> -->
					<u-icon name="volume" slot="icon" size="22" color="#2CB9A4"
						customStyle="margin: -3rpx 5rpx -3rpx 10rpx"></u-icon>
				</u-cell>
			</u-list-item>
		</u-list>
		<view class="noMore" v-if="last_page==page&&list.length!=0"
			style="text-align: center;color: #797575;margin-top: 20rpx;padding-bottom: 20rpx;">
			数据加载完成
		</view>
	</view>
</template>

<script>
	import {
		noticeList
	} from '@/request/api.js'
	export default {

		data() {
			return {
				list: [],
				last_page: 1,
				page: 1,
			}
		},
		onLoad() {
			this.loadmore()
		},
		onReachBottom() {
			console.log('lower')
			if (this.page < this.last_page) {
				this.page = this.page + 1
				this.loadmore()
			}
		},
		methods: {
			// scrolltolower(){
			// 	console.log('lower')
			// 	if (this.page < this.last_page) {
			// 		this.page = this.page + 1
			// 		this.loadmore()
			// 	}
			// },
			goDetails(e) {
				console.log(e)
				uni.navigateTo({
					url: `/pages/nearbyCar/noticeList/details?id=${e.id}`
				})
			},
			loadmore() {
				noticeList({page:this.page}).then(res => {
					if (res.msg == '成功') {
						this.last_page = res.data.last_page
						this.list = this.list.concat(res.data.data)
						// console.log(this.last_page,this.page)
					}
				})
			}
		},
	}
</script>
